package com.hzqy.service.virtualchannel;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateValue {
	/**
	 * 时分秒正则
	 */
	public static final String TIMEREGEX = "([0-1]?[0-9]|2[0-3])\\W([0-5][0-9])\\W([0-5][0-9])";
	//TIMEREGEX = "([0-1]?[0-9]|2[0-3])\\D{1}([0-5][0-9]):([0-5][0-9])";
	//TIMEREGEX = "([0-1]?[0-9]|2[0-3])\\W{1}([0-5][0-9]):([0-5][0-9])";
	//TIMEREGEX = "([0-1]?[0-9]|2[0-3])[：:]([0-5][0-9]):([0-5][0-9])";
	public static void main(String[] args) {
		String value = "03：58:07";
		boolean flag = validateByRegex(value, TIMEREGEX);
		System.out.println("flag:"+flag);
	}
	
	/**
	 * 验证值是否有效
	 * @param value
	 * @param regex
	 * @return
	 */
	public static boolean validateByRegex(String value,String regex){
		boolean flag = false;
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(value);
		if(m.matches())
			flag = true;
		return flag;
	}
}
